import { _decorator, Component, Node, Label, Sprite } from 'cc';
import {downloadImage} from "db://assets/script/utils/imageUtils";
const { ccclass, property } = _decorator;

@ccclass('AvatarView')
export class AvatarView extends Component {
    @property({
        type: Sprite,
        tooltip: "头像"
    })
    avatar: Sprite

    @property({
        type: Node,
        tooltip: "庄家"
    })
    zhuang: Node

    @property({
        type: Label,
        tooltip: "name"
    })
    nickname: Label

    @property({
        type: Sprite,
        tooltip: "score 图标"
    })
    scoreIcon: Sprite

    @property({
        type: Label,
        tooltip: "分数"
    })
    scoreNumber: Label


    start() {
        // 隐藏庄图标
        this.zhuang.active = false
        this.scoreNumber.string = "0"
    }

    updateAvatar(url: string) {
        downloadImage(url, this.avatar)
    }

    updateScore(score: string) {
        this.scoreNumber.string = score
    }

    updateNickname(name: string) {
        this.nickname.string = name
    }

    // 显示庄
    showZhuang() {
        this.zhuang.active = true
    }

    // // icon图标设为金豆房
    // setRubyScoreIcon() {
    //
    // }
}


